#!/bin/bash
dt=`date +%Y%m%d`
systemctl stop kube-apiserver
mv /etc/kubernetes/manifests /etc/kubernetes/manifests.bak
export ETCDCTL_API=3
#etcdctl snapshot restore /data/etcd-backup/ snapshot.db.2021-03-21-00-00 \
#--name etcd1 \
#--initial-cluster "etcd1=https://10.30.24.107:2380,etcd2=https://10.30.24.108:2380,etcd3=https://10.30.24.109:2380" \
#--initial-cluster-token k8s_etcd \
#--initial-advertise-peer-urls https://10.30.24.107:2380 \
#--data-dir=/data/etcd
etcdctl snapshot restore /root/backup/etcd-backup/etcd-snapshot_$dt.db --name=sgscc-uvl-app141.ych.com --endpoints="https://127.0.0.1:2379" --cacert=/etc/kubernetes/pki/etcd/ca.crt --key=/etc/kubernetes/pki/apiserver-etcd-client.key --cert=/etc/kubernetes/pki/apiserver-etcd-client.crt  --initial-cluster=sgscc-uvl-app141.ych.com=https://10.202.94.141:2380 --initial-advertise-peer-urls=https://10.202.94.141:2380 --initial-cluster-token=etcd-cluster-0 --data-dir=/var/lib/etcd1
systemctl start kube-apiserver
mv /etc/kubernetes/manifests.bak /etc/kubernetes/manifests
